#define _CRT_SECURE_NO_WARNINGS 1

#include "TreeNode.h"

void test1()
{
	STreeNode* root = TreeNodeCreate1();
	PreOrder(root);
	printf("\n");
	InOrder(root);
	printf("\n");
	PostOrder(root);
	printf("\n");
	LevelOrder(root);
	printf("\n");

	printf("%d\n", BinaryTreeSize(root));	//6
	printf("%d\n", BinaryTreeLeafSize(root));	//3
	printf("%d\n", BinaryTreeLevelKSize(root,3));	//3

	printf("%d\n", TreeHeight(root));	//3

}


void test2()
{
	STreeNode* root = TreeNodeCreate2();
	PreOrder(root);
	printf("\n");
	InOrder(root);
	printf("\n");
	PostOrder(root);
	printf("\n");
	LevelOrder(root);
	printf("\n");

	printf("%d\n", BinaryTreeSize(root));	//7
	printf("%d\n", BinaryTreeLeafSize(root));	//3
	printf("%d\n", BinaryTreeLevelKSize(root, 3));	//3

	printf("%d\n", TreeHeight(root));	//4

	printf("%p\n", BinaryTreeFind(root, 10));	//null

	printf("%d\n", BinaryTreeFind(root, 7)->Tdata);	//7

	BinaryTreeDestory(root);

}


void test3()
{
	STreeNode* root = TreeNodeCreate3();
	PreOrder(root);
	printf("\n");

	int arr[] = { 1,2,4,0,0,5,0,8,0,0,3,6,0,0,7,0,0 };
	int arr1[] = { 1,2,3,0,0,4,5,0,7,0,0,6,0,0,0 };

	int i = 0;
	STreeNode* root1 = BinaryTreeCreate(arr1, &i);

	i = 0;
	STreeNode* root2 = BinaryTreeCreate(arr, &i);

	PreOrder(root1);
	printf("\n");

	printf("%d\n", TreeHeight(root));	//5
	printf("%d\n", TreeHeight(root1));	//5
	printf("%d\n", TreeHeight(root2));	//4



}

void test4()
{
	int arr[] = { 1,2,4,0,0,5,0,8,0,0,3,6,0,0,7,0,0 };
	int i = 0;
	STreeNode* root = BinaryTreeCreate(arr, &i);
	LeveloPrint(root);

	printf("%d\n", BinaryTreeComplete(root));//0

	STreeNode* root1 = TreeNodeCreate1();
	printf("%d\n", BinaryTreeComplete(root1));//1

}

int main()
{

	//test1();
	test4();

	return 0;
}













